String.prototype.lenB   =   function(){return   this.replace(/[^\x00-\xff]/g,"**").length;}  

function hideMsg(){
		if(document.errMsgBlockId){
				
				var msgBodyTrObj = (window.document.getElementById(document.errMsgBlockId+"_body_tr"));
				
				var tableObj = (window.document.getElementById(document.errMsgBlockId+"_body_td"));
				
				var table_tbody = tableObj.childNodes[0];
		
				for(var i=(table_tbody.childNodes.length-1);i>=0;i--){
					table_tbody.removeChild(table_tbody.childNodes[i]);
				}
				
				if (msgBodyTrObj){
					
						  msgBodyTrObj.style.display = "none";
				}

		}
}

function showMsg(msgArrayObj,msgType){
  try{
			if(document.errMsgBlockId){
				var msgBodyTrObj = (window.document.getElementById(document.errMsgBlockId+"_body_tr"));
				if (msgBodyTrObj)
				{
					if (msgArrayObj==null || msgArrayObj.length==0){
						  msgBodyTrObj.style.display = "none";
						  return;
				  }
					msgBodyTrObj.style.display = "";
				}
				var rootpath = "..";
				if (CBILL_GLOBAL_OBJ && CBILL_GLOBAL_OBJ.contextPath){
					rootpath = CBILL_GLOBAL_OBJ.contextPath;
				}
				
				var tableObj = (window.document.getElementById(document.errMsgBlockId+"_body_td"));
				
				var msgColorTdObj = (window.document.getElementById(document.errMsgBlockId+"_msgColor_td"));
				
				var table_tbody = tableObj.childNodes[0];
		
				for(var i=(table_tbody.childNodes.length-1);i>=0;i--){
					table_tbody.removeChild(table_tbody.childNodes[i]);
				}
				if (tableObj) {
				    
				    if (msgType=="success"){
				        msgColorTdObj.className="rightTable";
				        var prefix = "&nbsp;&nbsp;<img src='" + rootpath +"/core/images/right.gif' />&nbsp;";
				    }else{
				        msgColorTdObj.className="errorTable";
				        var prefix = "&nbsp;&nbsp;<img src='" + rootpath +"/core/images/suggest1.gif' />&nbsp;";
				    }
						
					for (var i=0;i< msgArrayObj.length;i++ ){				
						var trNode = document.createElement("TR");
						var tdNode = document.createElement("TD");
						tdNode.innerHTML = prefix + msgArrayObj[i];
						tdNode.valign = "middle"; 
						tdNode.align='left'
						tdNode.className="black";
						trNode.appendChild(tdNode);
						table_tbody.appendChild(trNode);	
					}
		
				}
			}
			scrollTo(0,0);
  }catch(e){
     alert(e.description);
  }
}

function pagesKeydownHandler(obj,mainform){
   if (event.keyCode<48 || event.keyCode>57)
	{
	   event.returnValue = false;
	}
	if(event.keyCode==13){
		if (obj=="")
		   return;
		mainform.currentPageNo.value=obj.value;
		if(validateFormForPages(mainform)){
			validate_submit();
		}else{
			mainform.currentPageNo.value=1;validate_submit();
		}
	}
}

function getDate(offset)
{
	var now=new Date(); 
	var mill=(now.getTime()+offset*3600*24*1000);
	var newdate=new Date(mill);
	var ret=newdate.getFullYear() + "-" + ((newdate.getMonth()+1)<10?"0":"")  + (newdate.getMonth()+1) + "-" + (newdate.getDate()<10?"0":"") + newdate.getDate();
	return ret;
}



function relocation(URL)
{
	location=URL

}


function changeurl(urlStr)
{

var href = window.opener.location.href;

			href = href.substring(0, href.lastIndexOf("/") + 1);

			href = href + urlStr;
			
			self.window.close();
			window.opener.location.href = urlStr;

}



function pop(_tom){
	newwin=window.open(_tom,"ph","left=0,top=0,width=500,height=550,resizable=yes,scrollbars=yes");
	newwin.focus();
}



function setdate(obj)
{
	return new Date(obj.value.substring(0,4),obj.value.substring(5,7)-1,obj.value.substring(8,10));
}


function getDiff(objbegin,objend)
{
	
	 return ((setdate(objend)-setdate(objbegin))/(24*3600*1000));
}




function getOptionValue(obj) {
	var cbObj = obj;
	var count = 0;
	if (cbObj.checked) {
		return cbObj.value;
	}
	for (var i=0; i<cbObj.length; i++) {
		if (cbObj[i].checked) {
			return cbObj[i].value;
		} 
	}
	
}


function checkHandler(obj) {
	var cbObj =obj;
	var count = 0;
	if (cbObj.checked) {
		count++;
	}
	for (var i=0; i<cbObj.length; i++) {
		if (cbObj[i].checked) {
			count++;
		} 
	}
	if (count == 0) {
		return false;
	}
	if (count > 1) {
		return false;
	}
	return true
}


function HTMLEncode(text)
{
	text = text.replace(/&/g, "&amp;") ;
	text = text.replace(/"/g, "&quot;") ;
	text = text.replace(/</g, "&lt;") ;
	text = text.replace(/>/g, "&gt;") ;
	text = text.replace(/'/g, "&#146;") ;

	return text ;
}


function isIP(IPAddress) 
{ 
	
	var scount=0; 
	var ip = IPAddress; 
	var iplength = ip.length; 
	var Letters = "1234567890."; 
	for (i=0; i < IPAddress.length; i++) 
	{ 
		var CheckChar = IPAddress.charAt(i); 
		if (Letters.indexOf(CheckChar) == -1) 
		   return false; 
   
  } 

	for (var i = 0;i<iplength;i++) 
		(ip.substr(i,1)==".")?scount++:scount; 
	if(scount!=3) 
		return false; 

	first = ip.indexOf("."); 
	last = ip.lastIndexOf("."); 
	str1 = ip.substring(0,first); 
	subip = ip.substring(0,last); 
	sublength = subip.length; 
	second = subip.lastIndexOf("."); 
	str2 = subip.substring(first+1,second); 
	str3 = subip.substring(second+1,sublength); 
	str4 = ip.substring(last+1,iplength); 

	if (str1=="" || str2=="" ||str3== "" ||str4 == "") 
		return false; 
	
	if (str1< 0 || str1 >255) 
	    return false; 
	
	else if (str2< 0 || str2 >255) 
		return false; 

	else if (str3< 0 || str3 >255) 
		return false; 

	else if (str4< 0 || str4 >255) 
		return false; 
	return true;
}


function isEmail(MailAddress)
{

if(MailAddress.length!=0)
{
if (MailAddress.charAt(0)=="." || 
	MailAddress.charAt(0)=="@"|| 
	MailAddress.indexOf('@', 0) == -1 || 
	MailAddress.indexOf('.', 0) == -1 || 
	MailAddress.lastIndexOf("@")==MailAddress.length-1 || 
	MailAddress.lastIndexOf(".")==MailAddress.length-1)

	return false;

else
	 return true;
}
	return false;

}


function getPerfectVersion(vn,va)
{

	if(navigator.appName!=vn)
	{
		return false;
	}
	else  if(parseInt(navigator.appVersion)<va)
	{
		return false;
	}
	else 
	{
	
	return true;

	}


}


function getFloatValue(v){
	var ret = parseFloat((v+"").trim());
	if(ret == null || isNaN(ret) == true)
		return 0;
	return ret;
}

	
function getMoneyValue(str){
	return getFloatValue(str.replace(/,/g, ''));
}

	
function formatMoneyValue(value){
	var a = String(parseFloat(String(value)).toFixed(2));
	
	var rn = /^\d{1,3}(,\d{3})*\.\d\d$/;
	if(rn.test(a))
		return a;

	var r1 = /\d{4}\./;
	if(r1.test(a))
		a = a.replace(/(\d)(\d{3}\.)/,"$1,$2");
	else
		a = a.replace(/(\d)(\d{3})$/, "$1,$2");
	var r2 = /\d{4},/;
	while(r2.test(a))
		a = a.replace(/(\d)(\d{3},)/, "$1,$2");
	return a;
}


function cancookie()
{

document.cookie="testcookie";
cookieEnabled=(document.cookie=="testcookie")? true : false;
document.cookie="";

if (cookieEnabled) 
 return true;
else
  return false;

}

function tab (resourceId, url){
	this.resourceId = resourceId;
	this.url = url;
}


function tabClick(strUrl){
		var systime = (new Date()).getTime();
    if (strUrl.indexOf("?")>0){
       strUrl = strUrl + "&systime=" + systime;
    }else{
       strUrl = strUrl + "?systime=" + systime;
    }
	  window.location = strUrl;
}

function tabs (id, tab_Array, selectedInx, base,width){
	if (tab_Array.length != 0) {
        document.write("<table width='"+width+"' border='0' cellpadding='0' cellspacing='0'>\n");
        document.write("<tr>\n");
		for(i = 0; i < tab_Array.length; i++ ){
			 if (selectedInx == i) {
			    document.write("<td onclick=\"tabClick('" + tab_Array[i].url + "');\">\n");
			    document.write("<table id='" + id +"_" + i + "' width='100%' cellpadding='0' cellspacing='0' nowrop style='width:2%; cursor:hand;'>\n");
			    document.write("<tr>\n");
				  document.write("<td width='5'><img src='" + base + "/images/blue_left.gif' /></td>\n");
				  document.write("<td align='center' class='tab_button_blue' nowrap>&nbsp;" + tab_Array[i].resourceId + "&nbsp;</td>\n"); 
				  document.write("<td width='5'><img src='" + base + "/images/blue_right.gif' /></td>\n");
				  document.write("</tr>\n");
          document.write("</table>\n");
          document.write("</td>\n");
			 }else{
			    document.write("<td onclick=\"tabClick('" + tab_Array[i].url + "');\">\n");
			    document.write("<table id='" + id +"_" + i + "' width='100%' cellpadding='0' cellspacing='0' nowrop style='width:2%; cursor:hand;'>\n");
			    document.write("<tr>\n");
				  document.write("<td width='5' class='tab_underline1'><img src='" + base + "/images/gray_left.gif' /></td>\n");
				  document.write("<td align='center' class='tab_button_gray' nowrap>&nbsp;"+ tab_Array[i].resourceId+ "&nbsp;</td>\n");
				  document.write("<td width='5' class='tab_underline1'>"	+ "<img src='" + base + "/images/gray_right.gif' /></td>\n");
				  document.write("</tr>\n");
          document.write("</table>\n");
          document.write("</td>\n");
			 }
		    

		}
		document.write("<td width='98%' class='tab_underline1'>&nbsp;</td></tr></table>\n");
	}
}

function changePage(action,busiId,toPage,otherParam){
	//alert(toPage);
	if(toPage ==null || toPage == "") toPage = document.getElementById("currentPageNo").value;
	//document.getElementById("toPageNo").value = toPage;
	var url = action+"?act=changePage&busiId="+busiId+"&currentPageNo="+toPage+otherParam;
	location=url;
	//submit_ajax(url);	
	
}
function gotoPage(obj,maxPageNo,action,busiId,otherParam){
		if (event.keyCode==13){
		    if (obj.value==""){
		        return;
		    }
        	
        	if (parseInt(obj.value)>parseInt(maxPageNo)){
        		obj.value = maxPageNo;
        	}
   
        	obj.form.currentPageNo.value=obj.value;
        	changePage(action,busiId,obj.value,otherParam);	
		}else{
		
				if (event.keyCode>=48 && event.keyCode<=57)
				{
				   event.returnValue = true;
				}else{
				   event.returnValue = false;
				}
		}
}

function doPagination(frmName,pageNumber,toPageNo) {
		var frm = document.getElementById(frmName);
		if(frm){
		  pageNumber=(pageNumber && pageNumber>0)?pageNumber:1;
      toPageNo =(toPageNo && toPageNo>0)?toPageNo:1;
		  var url= frm.action;
		  if(url.indexOf('?')>0)
		     frm.action=url+"&currentPageNo="+pageNumber+"&toPageNo="+toPageNo;
		  else
		     frm.action=url+"?currentPageNo="+pageNumber+"&toPageNo="+toPageNo;
		  frm.submit();
		}
		return false;
}

function frameCheckChange(formObj,checked,checkValue,unCheckValue,descFieldName){

	if (!event) return;
	if (event.propertyName != 'checked'){
		return;
	}
	if (checked)
		formObj.item(descFieldName).value = checkValue;
	else
		formObj.item(descFieldName).value = unCheckValue;
	
}


function setValForInputFld(obj,val){
	if (obj){
		if (obj.value!=val)
			obj.value=val;
	}
}

function onTimeCtlTimeBlur2(obj,val){
	var valBak = val;
	if ( val <0)
		valBak = '00';
	if (val > 59)
		valBak = '59';
		
	if (val.length==1)
		valBak = "0" + val;
		
	setValForInputFld(obj,valBak);
	return valBak;
}

function onTimeCtlDateBlur(formObj,yearName,monthName,dayName,hourName,minuteName,secondName,fieldName){
	var gdCurDate = new Date();
	var year = gdCurDate.getFullYear();
	var month = "01";
	var day = "01";
	var hour = '00';
	var minute = '00';
	var second = '00';
	
	var yearObj = formObj.item(yearName);
	var monthObj = formObj.item(monthName);
	var dayObj = formObj.item(dayName);
	
	var hourObj = formObj.item(hourName);
	var minuteObj = formObj.item(minuteName);
	var secondObj = formObj.item(secondName);
	
	if (yearObj){
		if(yearObj.disabled=="true"){
		  return;
		}
		year = yearObj.value;
	}
	if (monthObj)
		month = monthObj.value;
	if (dayObj)
		day = dayObj.value;
	if (hourObj)
		hour = hourObj.value;
	if (minuteObj)
		minute = minuteObj.value;
	if (secondObj)
		second = secondObj.value;
	

	
	if( month.charAt(0) == '0' && month.length>=2 ) { month = month.substring(1,2); }
	if( day.charAt(0)   == '0' && day.length>=2) { day   = day.substring(1,2);   }
	if( hour.charAt(0) == '0' && hour.length>=2 ) { hour = hour.substring(1,2); }
	if( minute.charAt(0)   == '0' && minute.length>=2 ) { minute   = minute.substring(1,2);   }
	if( second.charAt(0)   == '0' && second.length>=2 ) { second   = second.substring(1,2);   }
	
	var nYear  = parseInt(year );
	var nMonth = parseInt(month);
	var nDay   = parseInt(day);
	
	var nHour  = parseInt(hour);
	var nMinute = parseInt(minute);
	var nSecond   = parseInt(second);
	
	
	var arrMon = new Array(12);

	if ( isNaN(nYear ) )	nYear=gdCurDate.getFullYear();
	if ( isNaN(nMonth) )	nMonth = 1;
	if ( isNaN(nDay  ) )	nDay = 1;
	
	if ( isNaN(nHour) )		nHour = 0;
	if ( isNaN(nMinute) )	nMinute = 0;
	if ( isNaN(nSecond ) )	nSecond = 0;

	arrMon[ 0] = 31;
	arrMon[ 1] = nYear % 4 == 0 ? 29:28;
	arrMon[ 2] = 31;
	arrMon[ 3] = 30;
	arrMon[ 4] = 31;
	arrMon[ 5] = 30;
	arrMon[ 6] = 31;
	arrMon[ 7] = 31;
	arrMon[ 8] = 30;
	arrMon[ 9] = 31;
	arrMon[10] = 30;
	arrMon[11] = 31;
	
	if ( nYear  < 1850 || nYear > 2100 ){
		year = gdCurDate.getFullYear();

	}
	
	setValForInputFld(yearObj,year);
	
	if ( nMonth < 1){
		month = "01";
	}else if (nMonth > 12){
		month = "12";
	}
	
	if (month.length==1)
		month = "0" + month;
		
	setValForInputFld(monthObj,month);
	
	
	if ( nDay < 1)
		day='01';
	else if (nDay > arrMon[nMonth - 1] )
		day=arrMon[nMonth - 1];
	
	if (day.length==1)
		day = "0" + day;
	
	setValForInputFld(dayObj,day);
	
	hour = onTimeCtlTimeBlur2(hourObj,nHour);
	minute = onTimeCtlTimeBlur2(minuteObj,nMinute);
	second = onTimeCtlTimeBlur2(secondObj,nSecond);

	
	//formObj.item(fieldName).value = year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second;
}

function onTimeCtlTagChgEvent(formObj,yearName,monthName,dayName,hourName,minuteName,secondName,fieldName){
	if (!event) return;
	if (event.propertyName != 'value'){
		return;
	}
	var gdCurDate = new Date();
	var year = gdCurDate.getFullYear();
	var month = '01';
	var day = '01';
	var hour = '00';
	var minute = '00';
	var second = '00';
	
	var yearObj = formObj.item(yearName);
	var monthObj = formObj.item(monthName);
	var dayObj = formObj.item(dayName);
	var hourObj = formObj.item(hourName);
	var minuteObj = formObj.item(minuteName);
	var secondObj = formObj.item(secondName);
	var fieldObj = formObj.item(fieldName);

	if (yearObj){
		if(yearObj.disabled=="true")
		  return;
		else
		 year = yearObj.value;
	}
	if (monthObj)
		month = monthObj.value;
	if (dayObj)
		day = dayObj.value;
	if (hourObj)
		hour = hourObj.value;
	if (minuteObj)
		minute = minuteObj.value;
	if (secondObj)
		second = secondObj.value;
	
	if (month=="") month = '01';
	if (day=="") day = '01';
	if (hour=="") hour = '00';
	if (minute=="") minute = '00';
	if (second=="") second = '00';
	
		
	if (fieldObj){
		if (year==""){
			fieldObj.value="";
		}else{
			fieldObj.value = year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second;
		}
	}
}


function onTimeCtlKeyDown(){
	if ((event.keyCode>=48 && event.keyCode<=57))
		event.returnValue = true;
	else
		event.returnValue = false;
}

function onPositiveNumberKeyDown(){
	if ((event.keyCode>=48 && event.keyCode<=57) || event.keyCode==13)
		event.returnValue = true;
	else
		event.returnValue = false;
}




function onTimeCtlTimeBlur(obj){
	if (obj.value=="")
		return;
	var val = parseInt(obj.value);
	if ( val <0)
		obj.value = '00';
	if (val > 59)
		obj.value = '59';
}

function TransformMap(data,exclude){
    var objList=[];
    exclude=exclude?exclude:[];
    if(data){
	    for(var i=0;i < data.length;i++){
	      var value=data[i];
	      var val=exclude[value[0]];
	      if(typeof(val)=="undefined"||val==null){
		      var obj={id:value[0],name:value[1]};
		      objList.push(obj);
	      }
	    }
    }
   return objList;
}
function doforEachElementDisabled(win){
  var frms=win.document.forms;
  if(frms){
     for(var i=0;i<frms.length;i++){
        var eles=frms[i].elements;
        if(eles){
           for(var j=0;j<eles.length;j++){
               var ele=eles[j];
               try{
               	if(ele.type){
               	  if(ele.type!="reset") ele.disabled=true;
               	  if(ele.type=="submit") ele.style.display="none";
               	}
               }catch(e){}
           }
           var imgs=document.getElementsByTagName("IMG");
           if(imgs && imgs.length){
           	  for(var j=0;j<imgs.length;j++){
           	  	var ele=imgs[j];
           	  	if(ele.src.indexOf("cal.gif")>-1) ele.style.display="none";
           	  }
           }
        }
     }
  }
}
function moveSel(selectName,nDir,fun){
  	  var selectObj=document.getElementById(selectName);
  	  if(selectObj){
	      if(selectObj.selectedIndex<0) return;   
	      if(nDir<0){
	      	if(selectObj.selectedIndex==0) return;   
	      }else{   
	        if(selectObj.selectedIndex==selectObj.options.length-1) return;   
	      }
	      var opt=selectObj.options[selectObj.selectedIndex];   
	      var otheropt=selectObj.options[selectObj.selectedIndex+nDir];   
	      var text=opt.text;   
	      var value=opt.value;    
	      opt.text=otheropt.text;   
	      opt.value=otheropt.value;   
	      otheropt.text=text;   
	      otheropt.value=value;   
	      selectObj.selectedIndex+=nDir;
	      if(typeof(fun)=="function") fun(selectObj);
     } 
}
//ternary select Class begin
function TernarySelect(objName,eleName,typeName,width){
	 this.objName=objName?objName:null;
	 this.obj=null;
	 this.typeName=typeName?typeName:"radio";
	 this.eleName=eleName?eleName:null;
	 this.arrs=[];
	 this.isFirst=true;
	 this.width=width || "120";//"320";
	 this.add=function(key,value){
	 	 this.arrs[key]=value;
	 };
	 this.get=function(key){
	 	 return this.arrs[key];
	 };
	 this.size=function(){
	 	 return this.arrs.length;
	 };
	 this.getObj=function(){
	 	 return (this.obj==null)?document.getElementById(this.objName):this.obj;
	 };
	 this.remove=function(key){
	 	 this.arrs[key]=null;
	   var temp=[];
	   for(var k in this.arrs){
	     	if(key!=k){temp[k]=this.arrs[k];}
	   }
	   this.arrs.length=0;
	   this.arrs=temp;
	   //temp.length=0;
	 };
	 this.addInput=function(targetObject,elementName,ele,isChecked){
		  var str=("<div valign='top' width'"+this.width+"'>");
		  var isCheckedstr=(isChecked || (this.size()==0 && !this.isFirst))?"checked ":"";
		  var divObject = document.createElement("div");
		  divObject.valign="top";
			divObject.style.width=this.width;
		  var elname=null;
		  if(this.eleName!=null) 
		     elname=this.eleName;
		  else
		  	 elname=elementName;
			str=("<INPUT "+isCheckedstr+" TYPE='")+this.typeName+("'  NAME='")+elname+("' VALUE='")+ele.value+("'>");
	    var newId = document.createElement(str);
	    /*var newId = document.createElement("INPUT");
	        newId.type=this.typeName;
	        newId.checked=isOneChecked;
	        newId.name=elname;
	        newId.value=ele.value;*/
	    divObject.appendChild(newId);
	    var newText = document.createElement("font");
	    newText.innerText=ele.text;
	    divObject.appendChild(newText);
	    targetObject.appendChild(divObject);
	    this.add(ele.value,divObject);
    };
    this.removeInput=function(targetObject,elementObject){
	    if(targetObject && elementObject){
	    	targetObject.removeChild(elementObject);
	    }
    }
}


TernarySelect.prototype={
	 addInputObj:function(elementName,key,val,isChecked){
	 	  var ele={value:key,text:val};
		  this.addInput(this.getObj(),elementName,ele,isChecked);
   },
   target:function(objName){
	 	  this.objName=objName;
   },
   removeInputObj:function(elementKey){
	    this.removeInput(this.getObj(),this.get(elementKey));
	    this.remove(elementKey);
   },
	 groupRight:function(srcProperty,decProperty){
		 for (i = 0; i <= srcProperty.options.length - 1; i++) {
	        if (srcProperty.options[i].selected) {
	        	  var element=document.createElement("OPTION");
              element.text=srcProperty.options[i].text;
              element.value=srcProperty.options[i].value;
	            element.selected="true";
	            decProperty.options.add(element);
	            this.isFirst=false;
	            this.addInput(this.getObj(),decProperty,element);
	        }
	    }
	    for (i = 0; i < srcProperty.options.length; i++) {
	        if (srcProperty.options[i].selected) {
	            srcProperty.remove(i);
	            i = i - 1;
	        }
	    }
	    return false;
  },
	groupLeft:function(srcProperty,decProperty){
		 for (i = 0; i <= decProperty.options.length - 1; i++) {
	        if (decProperty.options[i].selected) {
	        	  var element=document.createElement("OPTION");
              element.text=decProperty.options[i].text;
              element.value=decProperty.options[i].value;
	            //element.selected="false";
	            srcProperty.options.add(element);
	            this.removeInputObj(element.value);
	        }
	    }
	    for (i = 0; i < decProperty.options.length; i++) {
	        if (decProperty.options[i].selected) {
	            decProperty.remove(i);
	            i = i - 1;
	        }
	    }
	    return false;
  },
  groupRightAll:function(srcProperty,decProperty){
		for (i = 0; i < srcProperty.options.length; i++) {
	        srcProperty.options[i].selected = true;
	        var element=document.createElement("OPTION");
          element.text=srcProperty.options[i].text;
          element.value=srcProperty.options[i].value;
	        element.selected="true";
	        decProperty.options.add(element);
	        this.isFirst=false;
	        this.addInput(this.getObj(),decProperty,element);
	    }
	    for (i = 0; i < srcProperty.options.length; i++) {
	        srcProperty.options[i].selected = true;
	        srcProperty.remove(i);
	        i = i - 1;
	    }
	    return false;
  },
  groupLeftAll:function(srcProperty,decProperty){
	  for (i = 0; i < decProperty.options.length; i++) {
        decProperty.options[i].selected = true;
        var element=document.createElement("OPTION");
        element.text=decProperty.options[i].text;
        element.value=decProperty.options[i].value;
        srcProperty.options.add(element);
        this.removeInputObj(element.value);
    }
    for (i = 0; i < decProperty.options.length; i++) {
        decProperty.options[i].selected = true;
        decProperty.remove(i);
        i = i - 1;
    }
    return false;
  },
  doUpDown:function(selectName,nDir){
  	  var selectObj=document.getElementById(selectName);
  	  if(selectObj){
	      if(selectObj.selectedIndex<0) return;   
	      if(nDir<0){
	      	if(selectObj.selectedIndex==0) return;   
	      }else{   
	        if(selectObj.selectedIndex==selectObj.options.length-1) return;   
	      }
	      var opt=selectObj.options[selectObj.selectedIndex];   
	      var otheropt=selectObj.options[selectObj.selectedIndex+nDir];   
	      var text=opt.text;   
	      var value=opt.value;    
	      opt.text=otheropt.text;   
	      opt.value=otheropt.value;   
	      otheropt.text=text;   
	      otheropt.value=value; 
	      selectObj.selectedIndex+=nDir;
     } 
  }
}
//ternary select Class end

function DatToString(){   
  var sysDate=new Date();   
  var strDate=sysDate.getFullYear()+"-";   
  strDate+=(sysDate.getMonth()+1)+"-";   
  strDate+=sysDate.getDate();   
  return(strDate);   
}
function doDeleteWin(uri,frm){
	    if(uri){
	    	var win=document.getElementById("delete_Iframe");
	    	if(frm){
	    	  var arg=uri.indexOf("?")>0?"&":"?";
	    	  uri=uri+arg+"frm="+frm;
	      }
	    	if(win){
	    		win.location.href=uri;
	    	}else{
				  //var str="<iframe src='"+uri+"' id='delete_Iframe' name='_delete_Iframe' valign ='top' width='0'  height='0' scrolling='no' FRAMEBORDER='0' style='display:none;'>";
				  win = document.createElement("iframe");
				  win.src=uri;
				  win.id="delete_Iframe";
				  win.name="delete_Iframe";
				  win.valign="top";
				  win.width="0";
				  win.height="0";
				  win.scrolling="no";
				  win.frameborder="0";
				  win.style.display="none";
			    document.appendChild(win);
		    }  
	   }
	   return false;
}
//contextmenu begin
function Contextmenu(objName){
	this.contextName=objName;
	this.context=null;
	this.topPos=20;
	this.leftPos=60;
	document.oncontextmenu=function(){return false;};
	this.getContext=function(){
      if(this.context==null) this.context=document.getElementById(this.contextName);
	 	  return this.context;
  }
}
Contextmenu.prototype.setOffsetTop=function(topPos){this.topPos=topPos;};
Contextmenu.prototype.setOffsetLeft=function(leftPos){ this.leftPos=leftPos;};
Contextmenu.prototype.showMenu=function(itemId,e){
   if(e){
		 	  var element = e; 
			  var xPos = element.offsetLeft; 
			  var yPos = element.offsetTop;
			  while( element=element.offsetParent){
			        yPos += element.offsetTop; 
			        xPos += element.offsetLeft; 
			  }
			  var obj=this.getContext();
			  var _hight=0;
			  var sLeft=0;
			  var sHeight=0;
			  var sWidth=0;
			  var offtop=0;
			  obj.style.left=xPos+this.leftPos;
			  obj.style.top=yPos+this.topPos;
			  obj.style.position="absolute";
			  obj.style.display="";
			  document.onclick=function(){obj.style.display="none";};
			  return false;
	 }
};
Contextmenu.prototype.oncontextmenu=function(fun){
	      if(fun&&typeof(fun)=="function"){
				  var obj=this.getContext();
				  document.body.oncontextmenu=function(){
				  	if(obj.style.display=="none"){
				  	   obj.style.display="";
				  	   fun();
				  	}else
				  		 obj.style.display="none"
				  };
				  document.ondblclick=function(){obj.style.display="none";};
			  }
			  return false;
};    
function addDiv(aa){
  var obj=document.getElementById("com"+aa);
	var showDiv=document.createElement("<div id=\"showDiv"+aa+"\">")
	showDiv.appendChild(obj);
  document.getElementById("showCom").appendChild(showDiv);
  document.getElementById("hiddenCom").removeChild( document.getElementById("hiddenDiv"+aa));
}
function removeDiv(aa){
  var obj=document.getElementById("com"+aa);
	var hiddenDiv=document.createElement("<div id=\"hiddenDiv"+aa+"\">")
	hiddenDiv.appendChild(obj);
  document.getElementById("hiddenCom").appendChild(hiddenDiv);
  document.getElementById("showCom").removeChild( document.getElementById("showDiv"+aa));
}
function upAndDown(objName){
  objName=objName||"rightHaveChoosenList";
  var _obj=document.getElementById(objName);
  if(_obj){
		for(var i=0;i<_obj.options.length;i++){
	    var aa=_obj.options[i].value
	    var obj=document.getElementById("com"+aa);
		  var midDiv=document.createElement("<div id=\"midDiv"+aa+"\">")
		  midDiv.appendChild(obj);
	    document.getElementById("midCom").appendChild(midDiv);
	    document.getElementById("showCom").removeChild( document.getElementById("showDiv"+aa));
		}
		for(var i=0;i<_obj.options.length;i++){
	    var aa=_obj.options[i].value
	    var obj=document.getElementById("com"+aa);
		  var showDiv=document.createElement("<div id=\"showDiv"+aa+"\">")
		  showDiv.appendChild(obj);
	    document.getElementById("showCom").appendChild(showDiv);
	    document.getElementById("midCom").removeChild( document.getElementById("midDiv"+aa));
		}
  }
}

function moveSelCom(selectName,nDir){

  	  var selectObj=document.getElementById(selectName);
  	  if(selectObj){
	      if(selectObj.selectedIndex<0) return;   
	      if(nDir<0){
	      	if(selectObj.selectedIndex==0) return;   
	      }else{   
	        if(selectObj.selectedIndex==selectObj.options.length-1) return;   
	      }
	      var opt=selectObj.options[selectObj.selectedIndex];   
	      var otheropt=selectObj.options[selectObj.selectedIndex+nDir];   
	      var text=opt.text;   
	      var value=opt.value;    
	      opt.text=otheropt.text;   
	      opt.value=otheropt.value;   
	      otheropt.text=text;   
	      otheropt.value=value;   
	      selectObj.selectedIndex+=nDir;
	     
	      upAndDown();
     } 
}
//for multiSelect
function groupRightCom(srcProperty,decProperty) {
    for (i = 0; i <= srcProperty.options.length - 1; i++) {
        if (srcProperty.options[i].selected) {
            var element = window.Option.create(srcProperty.options[i].text, srcProperty.options[i].value, 0);
            element.selected="true";
          //adding of charels
            
           addDiv(srcProperty.options[i].value);
       
            //end adding of chales
            decProperty.options.add(element);
        }
    }
    for (i = 0; i < srcProperty.options.length; i++) {
        if (srcProperty.options[i].selected) {
            srcProperty.remove(i);
            i = i - 1;
        }
    }
    return;
}
function groupLeftCom(srcProperty,decProperty) {
    for (i = 0; i <= decProperty.options.length - 1; i++) {
        if (decProperty.options[i].selected) {
            var element = window.Option.create(decProperty.options[i].text, decProperty.options[i].value, 0);
            //element.selected="false";
            srcProperty.options.add(element);
        }
    }
    for (i = 0; i < decProperty.options.length; i++) {
        if (decProperty.options[i].selected) {
          //adding of charels
          
            removeDiv(decProperty.options[i].value);
            //end adding of chales
            decProperty.remove(i);
            i = i - 1;
        }
    }
    return;
}
function groupRightAllCom(srcProperty,decProperty) {
    for (i = 0; i < srcProperty.options.length; i++) {
        srcProperty.options[i].selected = true;
        var element = window.Option.create(srcProperty.options[i].text, srcProperty.options[i].value, 0);
        element.selected="true";
        decProperty.options.add(element);
         //adding of charel
        addDiv(srcProperty.options[i].value);      
        //end adding of chales
    }
    for (i = 0; i < srcProperty.options.length; i++) {
        srcProperty.options[i].selected = true;
        srcProperty.remove(i);
        i = i - 1;
    }return;
}
function groupLeftAllCom(srcProperty,decProperty) {
    for (i = 0; i < decProperty.options.length; i++) {
      
        decProperty.options[i].selected = true;
        var element = window.Option.create(decProperty.options[i].text, decProperty.options[i].value, 0);
        //element.selected="false";
        srcProperty.options.add(element);
    }
    for (i = 0; i < decProperty.options.length; i++) {
             //adding of charels
           removeDiv(decProperty.options[i].value);
            //end adding of chales
        decProperty.options[i].selected = true;
        decProperty.remove(i);
        i = i - 1;
       
    }return;
}
//the pricingPlan fo compant ,charles add end
//contextmenu end
//the checkbox chang to disabled or undisabled begin
function childDisabledOrUnDisabled(ele,flag,fun){
   	if(ele){
   	   try{flag=(typeof(flag)=="boolean")?flag:ele.disabled;}catch(e){}
   	   var childs=ele.childNodes;
   	   if(childs && childs.length>0){
   	      for(var i=0;i<childs.length;i++){
   	         var obj=childs[i];
   	         childDisabledOrUnDisabled(obj,flag,fun);
   	         try{
   	         	var isExecute=true;
   	          if(obj.tagName=="SELECT" || obj.tagName=="INPUT" || obj.tagName=="TEXTAREA"){
	   	         	if(typeof(fun)=="function"){
	   	         		isExecute=fun(obj);
	   	         	}
	   	         	if(isExecute) obj.disabled=flag;
   	          }
   	         }catch(e){}
   	      }
   	   }
   	}
}
function doCheckInit(flag){
  flag=flag ||true;
	var checks=document.getElementsByTagName("INPUT");
	for(var i=0;i<checks.length;i++){
	 var chk=checks[i];
	 if(chk&&chk.type=="checkbox"){
	    chk.checked=flag;
	    chk.click();
	  }
	}
}
//end



